<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Vue实例-生命周期函数</title>
  <script src="../asset/js/vue.js"></script>
</head>
<div id="app">
</div>

<body>
  <script>
    /* 一个Vue的实例
     *生命周期函数就是Vue实例在某一个时间点会自动执行的函数
     */
    var vm = new Vue({
      el: '#app',
      data: {
        message: 'hello world'
      },
      template: '<div>{{this.message}}</div>',
      methods: {},
      beforeCreate() {
        console.log('beforeCreate')
      },
      created() {
        console.log('created')
      },
      beforeMount() {
        console.log(this.$el)
        console.log('beforeMount')
      },
      mounted() {
        console.log(this.$el)
        console.log('mounted')
      },
      /* vm这个实例被销毁（vm.$destroy()），会执行下面的生命周期函数 */
      beforeDestroy() {
        console.log('beforeDestroy')
      },
      destroyed() {
        console.log('destroyed')
      },
      /* data里面的数据更新 */
      updated() {
        console.log('update')
      },
      beforeUpdate() {
        console.log('beforeUpdate')
      }
    })
  </script>
</body>

</html>